﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AioNightly.Model;
using AioNightly.Common;

namespace AioNightly
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        private MenuItem defaultItem;
        private MenuItem aboutItem;
        private MenuItem newnoteItem;
        private MenuItem adminItem;

        protected void Page_Load(object sender, EventArgs e)
        {
            User me = (User)Session["User"];
            if (me!=null)
            {
                NavigationMenu.Items.Clear();

                InitMenuItems();
                
                NavigationMenu.Items.Add(defaultItem);
                
                switch (me.Type)
                {
                    case (int)UserManager.UserType.Master:
                        NavigationMenu.Items.Add(newnoteItem);
                        NavigationMenu.Items.Add(adminItem);
                        break;

                    case (int)UserManager.UserType.Dev:
                        NavigationMenu.Items.Add(newnoteItem);
                        break;

                    case (int)UserManager.UserType.Qa:
                        break;

                    default:
                        break;
                }

                NavigationMenu.Items.Add(aboutItem);
            }
        }

        private void InitMenuItems()
        {
            defaultItem = new MenuItem("Home");
            defaultItem.NavigateUrl = @"~/Default.aspx";

            aboutItem = new MenuItem("About");
            aboutItem.NavigateUrl = @"~/About.aspx";

            newnoteItem = new MenuItem("Add Note");
            newnoteItem.NavigateUrl = @"~/New.aspx";

            adminItem = new MenuItem("Admin");
            adminItem.NavigateUrl = @"~/Admin.aspx";
        }
    }
}
